
// n位数 * m位数 = 结果位数最大为m+n

char * multiply(char * num1, char * num2){
    if (strcmp(num1, "0") == 0 || strcmp(num2, "0") == 0) return "0";
    int len1 = strlen(num1), len2 = strlen(num2);
    int len = len1+len2;
    int *res = calloc(len, sizeof(int));
    int i, j;
    for (i = len1-1; i >= 0; i--) {
        int n1 = (num1[i]-'0');
        for (j = len2-1; j >= 0; j--) {
            int n2 = (num2[j]-'0');
            int sum =  res[i+j+1] + n1*n2; 
            res[i+j+1] = sum % 10;  
            res[i+j] += sum / 10 ;  //进位
        }
    }
    // for (i = 0; i < len; i++)
    //     printf("%d ",res[i]);
    int cnt = 0;
    char *multi = malloc(sizeof(char) * (len+1));
    for (i = 0; i < len; i++) {
        if (i == 0 && res[i] == 0) continue;
        multi[cnt++] = res[i] + '0';
    }
    multi[cnt] = '\0';
    free(res);
    return multi;
}